import Controller.*;
import lejos.nxt.*;

public class NHoek {

	public static void main(String[] args) {

		OrangeController oc = new OrangeController();
		
		double sides = 0;
		double increment = 0.1;
		LCD.drawString("Increment: " + increment + "    ",0,2 );
		LCD.drawString("Zijde: " + sides + "        " ,0,3);

		Buttonloop: {
			while (true)
			{
				int button = Button.waitForPress();
				switch (button) {
				case 1: break Buttonloop;
				case 2: sides -= increment; if(sides<0.1) sides=0.1; break;
				case 4: sides += increment; break;
				case 8: if (increment < 1)
							increment = 1.0;
						else if (increment < 10)
							increment = 10.0;
						else
							increment = 0.1;
				
				}
				LCD.drawString("Increment: " + increment + "cm     ",0,2 );
				LCD.drawString("Zijde: " + sides + "cm     " ,0,3);
			}
		}
		int corners = 3;
		LCD.drawString("                                        ",0,2 );
		LCD.drawString("Hoeken: " + corners + "         " ,0,3);
		Buttonloop2: {
			while (true)
			{
				int button = Button.waitForPress();
				switch (button) {
				case 1: break Buttonloop2;
				case 2: corners--; if(corners<3) corners=3; break;
				case 4: corners++; break;
				}
				LCD.drawString("Hoeken: " + corners + "         " ,0,3);
			}
		}
		
		for(int n=0; n<corners; n++) {
			oc.forward(sides);
			oc.turnCW(360.0/(double)(corners));
		}
		
	}

}
